﻿<Window x:Class="Adaptive.ReactiveTrader.Client.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:behaviors="clr-namespace:Adaptive.ReactiveTrader.Client.UI.Behaviors"
        Title="Reactive Trader" Height="800" Width="1024">
    <Window.Style>
        <Style TargetType="Window">
            <Style.Resources>
                <SolidColorBrush x:Key="CloseButtonBrush" Color="#FFC7CCD0" />
            </Style.Resources>
            <Setter Property="Icon" Value="Styles\adaptive-logo.png"/>
            <Setter Property="Background" Value="#FFDEE3E8"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="SnapsToDevicePixels" Value="True"/>
            <Setter Property="WindowChrome.WindowChrome">
                <Setter.Value>
                    <WindowChrome GlassFrameThickness="-1" ResizeBorderThickness="4" CaptionHeight="30" UseAeroCaptionButtons="False" CornerRadius="0" />
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Window">
                        <ControlTemplate.Resources>
                            <Style x:Key="CloseButtonStyle" TargetType="Button">
                                <Setter Property="Width" Value="45" />
                                <Setter Property="Height" Value="20" />
                                <Setter Property="Background" Value="{StaticResource CloseButtonBrush}" />
                                <Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="Button">
                                            <Border Background="{TemplateBinding Background}">
                                                <Path Data="M8,0L7,0 4,2.571 1,0 0,0 0,1 2.917,3.5 0,6 0,7 1,7 4,4.429 7,7 8,7 8,6 5.083,3.5 8,1z" Fill="Black" Height="7" Width="8" VerticalAlignment="Center" HorizontalAlignment="Center" />
                                            </Border>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter Property="Background" Value="#FFE04343" />
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <Style x:Key="MinMaxButtonStyle" TargetType="Button">
                                <Setter Property="Width" Value="24" />
                                <Setter Property="Height" Value="20" />
                                <Setter Property="Margin" Value="1,0" />
                                <Setter Property="Background" Value="Transparent" />
                                <Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="Button">
                                            <Border Background="{TemplateBinding Background}">
                                                <ContentPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Content="{TemplateBinding Content}" />
                                            </Border>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter Property="Background" Value="#FF3665B3" />
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ControlTemplate.Resources>
                        <Border x:Name="RootBorder" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="30" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>

                                <Grid Grid.Row="0">
                                    <Border Height="1" Background="{StaticResource CloseButtonBrush}" VerticalAlignment="Top" />

                                    <TextBlock HorizontalAlignment="Center" Text="{TemplateBinding Title}" Foreground="Black" FontSize="16" />

                                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,7,0">
                                        <Button Style="{StaticResource MinMaxButtonStyle}" VerticalContentAlignment="Bottom">
                                            <i:Interaction.Behaviors>
                                                <behaviors:MinimizeWindowButtonBehavior AssociatedWindow="{Binding RelativeSource={RelativeSource TemplatedParent}}"/>
                                            </i:Interaction.Behaviors>
                                            <Path Data="M0,0L8,0 8,2 0,2z" Fill="Black" Height="2" Width="8" Margin="0,0,0,7" />
                                        </Button>
                                        <Button Style="{StaticResource MinMaxButtonStyle}">
                                            <i:Interaction.Behaviors>
                                                <behaviors:MaximizeWindowButtonBehavior AssociatedWindow="{Binding RelativeSource={RelativeSource TemplatedParent}}"/>
                                            </i:Interaction.Behaviors>
                                            <Path Data="M9,7L1,7 1,2 9,2z M0,8L10,8 10,0 0,0z" Fill="Black" Height="8" Width="10" />
                                        </Button>
                                        <Button Style="{StaticResource CloseButtonStyle}">
                                            <i:Interaction.Behaviors>
                                                <behaviors:CloseWindowButtonBehavior AssociatedWindow="{Binding RelativeSource={RelativeSource TemplatedParent}}"/>
                                            </i:Interaction.Behaviors>
                                        </Button>
                                    </StackPanel>
                                </Grid>

                                <ContentPresenter Grid.Row="1" Content="{TemplateBinding Content}" />
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="WindowState" Value="Maximized">
                    <Setter Property="BorderThickness" Value="8" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Style>
</Window>
